package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ShoppingMapper {
    /**
     * 查询菜品是否在购物车
     * @param shoppingCart
     * @return
     */
    List<ShoppingCart> get(ShoppingCart shoppingCart);

    /**
     * 修改
     * @param cart
     */
    void update(ShoppingCart cart);

    /**
     * 添加
     * @param shoppingCart
     */
    void save(ShoppingCart shoppingCart);


    /**
     * 查看购物车
     * @param userId
     * @return
     */
    @Select("select *from sky_take_out.shopping_cart where user_id=#{userId}")
    List<ShoppingCart> list(Long userId);

    /**
     * 清空购物车
     * @param userId
     */
    @Delete("delete from sky_take_out.shopping_cart where user_id=#{userId}")
    void clear(Long userId);

    /**
     * 删除某一个套餐或菜品
     * @param shoppingCart
     */
    void del(ShoppingCart shoppingCart);

    /**
     *批量添加
     * @param shoppingCartList
     */
    void saveAll(List<ShoppingCart> shoppingCartList);
}
